﻿using CNKI.TPI.Web.Search.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace CNKI.TPI.Web.Admin.IDAO
{
    public interface ISingleDBPublishDAO
    {
       
        /// <summary>
        /// 获取所有数据库列表
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE> GetDBList(IList<SearchType> SearchTypeList = null);
             /// <summary>
        /// 获取所有数据库列表 分页
        /// </summary>
        /// <returns></returns>
       IList<SYS_CMS_DATABASE> GetDBListPageSize(Expression<Func<SYS_CMS_DATABASE, bool>> match, int start, int length, out int count,
            Expression<Func<SYS_CMS_DATABASE, bool>> order = null,
            bool loadLazy = false, string tableName = null, string ctxName = null);
        
         /// <summary>
       /// 获得数据库字段
       /// </summary>
       /// <param name="dbID"></param>
       /// <returns></returns>
       IList<SYS_CMS_DATABASE_FIELD> GetDBField(string dbCode);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbCode"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        SYS_CMS_DATABASE_FIELD GetDBField(string dbCode, string fieldName);
        /// <summary>
        /// 获得数据库发布模板信息
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_PUBLISHTYPE> GetTemplateList();
       /// <summary>
       /// 更新数据库表 发布字段
       /// </summary>
       /// <param name="obj"></param>
       /// <returns></returns>
       bool UpdatetDBPubFlag(string DbID, int flag);
       /// <summary>
       /// 保存数据库发布字段（SYS_CMS_DATABASE_PUBLISH_FIELD）
       /// </summary>
       /// <param name="obj"></param>
       /// <returns></returns>
       bool InsertPublicField(SYS_CMS_DATABASE_PUBLISH_FIELD obj);
       /// <summary>
       /// 删除数据库发布字段（SYS_CMS_DATABASE_PUBLISH_FIELD）
       /// </summary>
       /// <param name="obj"></param>
       /// <returns></returns>
       bool DeletePublicField(Expression<Func<SYS_CMS_DATABASE_PUBLISH_FIELD, bool>> query);

      /// <summary>
        /// 获取已经设置的字段
        /// </summary>
        /// <param name="dbID"></param>
        /// <param name="type"></param>
        /// <returns></returns>
       IList<SYS_CMS_DATABASE_PUBLISH_FIELD> GetField(string dbID, FieldType type);


         /// <summary>
        /// 更新数据库表 保存发布形式
      /// </summary>
      /// <param name="DbID">数据库ID</param>
      /// <param name="templateID">模板ID</param>
      /// <param name="visibleFlage">是否显示</param>
  /// <param name="dbsort">排序</param>
      /// <returns></returns>
       bool UpdatetDBTemplate(string DbID, string templateID, string visibleFlage, string dbsort);
       
        /// <summary>
        /// 保存显示名称
        /// </summary>
        /// <param name="DbID"></param>
        /// <param name="Name"></param>
        /// <param name="DisplayName"></param>
        /// <returns></returns>
       bool UpdatetDBDisplayName(string DbID, string Name, string DisplayName);

        /// <summary>
        /// 获得数据库字段
        /// </summary>
        /// <param name="fieldList"></param>
        /// <returns></returns>
       IList<SYS_CMS_DATABASE_FIELD> GetDBFieldByID(IList<int> fieldList);
           /// <summary>
        /// 更改数据库显示顺序
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        bool UpdateDBSort(IList<SYS_CMS_DATABASE> list);
          /// <summary>
        /// 获得已经设置关联的数据库
        /// </summary>
        /// <param name="dbCode">dbcode为空时，获取所有数据</param>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE_RELATION> GetDbRelation(string dbCode);

          /// <summary>
        /// 保存关联数据库
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        bool InsertRelation(SYS_CMS_DATABASE_RELATION obj);
        /// <summary>
        /// 删除数据库关联数据
        /// </summary>
        /// <param name="dbcode"></param>
        /// <returns></returns>
        bool DeleteRelation(string dbcode);

    }
}